home *** CD-ROM | disk | FTP | other *** search
/ Light ROM 1 / LIGHT-ROM 1 (Amiga Library Services)(1994).iso / ffdisks / d916.lha / ScreenMode / Auto.doc next >
Text File  |  1993-10-04  |  7KB  |  194 lines

  1.  
  2.       ====================== ScreenModeRequester =====================
  3.  
  4.  
  5. -------------------------------------------------------------------------------
  6.  
  7. NAME
  8.     UserScreenMode -- Open a ScreenModeRequester to ask the user about the
  9.                       ModeID, size, depth and overscan-info for the screen
  10.                       you are about to open.
  11.  
  12. SYNOPSIS
  13.  
  14.     extern int __asm UserScreenMode( register __a1 UBYTE *   PublicScreenName,
  15.                                      register __a2 SCRMODE * DataToFill,
  16.                                      register __a3 PRPT **   PropList );
  17.  
  18.     ok = UserScreenMode( PublicScreenName, DataToFill, PropList )
  19.     d0                          a1             a2         a3
  20.  
  21. FUNCTION
  22.     This function opens a requester and shows all possible ModeID's in several
  23.     (changeable) lists. The programmer can include or exclude the properties he
  24.     wants to support. The user can select one of these modes, change the width,
  25.     height and depth and the displaysize (overscan).
  26.  
  27. INPUTS
  28.     PublicScreenName
  29.         A pointer to the name of the PUBLIC screen you want the requester to
  30.         appear on. A NULL pointer will open the requester on the default public
  31.         screen.
  32.  
  33.     DataToFill
  34.         A pointer to a "SCRMODE" structure (see "UserScreenMode.h"). If
  35.         "UserScreenMode()" returns TRUE (1) you can use the variables in this
  36.         structure to open a screen.
  37.         Otherwise the structure won't have been changed.
  38.  
  39.     PropList
  40.         A pointer to an array of _pointers_ to "PRPT" structures (see
  41.         "UserScreenMode.h"), ending with a NULL pointer. They will be used for
  42.         the properties gadget. With this list you can include or exclude any
  43.         mode with a certain property in the listview gadget; t.i. the
  44.         selectable display modes. See the example below.
  45.  
  46. RESULT
  47.     A TRUE (1) result may be expected when the user made a choise. All other
  48.     situations (including errors) will result in a FALSE (0).
  49.     Errors can be found in the "USM_Error" variable. See the example below.
  50.  
  51. NOTE
  52.     The library-pointers IntuitionBase, GFXBase and GadToolsBase should be
  53.     defined in your code, but you don't have to open these libraries if your
  54.     code doesn't need them.
  55.  
  56. COPYRIGHT
  57.     (c) ASWare 1993, by Ekke Verheul. This function is FREEWARE, you may link it
  58.     with your own source without letting me know - as long as you don't change
  59.     anything in the object (like the copyright). If you need to make changes or
  60.     if you want to use this object for a commercial product REGISTER FIRST!
  61.     If you register you will receive the latest versions of all my PD-stuff,
  62.     including the full source of "UserScreenMode". Read the ReadMe file!
  63.  
  64. EXAMPLE
  65.  
  66.     #include <exec/types.h>
  67.     #include <intuition/intuition.h>
  68.     #include <clib/exec_protos.h>
  69.     #include <clib/dos_protos.h>
  70.     #include <clib/intuition_protos.h>
  71.     #include <stdio.h>
  72.  
  73.     #define USM_ERRTXT                   //--- define this BEFORE ...
  74.                                          //--- .. #include "UserScreenMode.h",
  75.                                          //--- if you want to use USM_ERROR.
  76.     #include "UserScreenMode.h"
  77.  
  78.     struct GfxBase *GfxBase;             //---> Those must be defined,
  79.     struct IntuitionBase *IntuitionBase; //---> not necessaryly opened.
  80.     struct Library *GadToolsBase;        //--->         -*-
  81.  
  82.     PRPT proplist[] =
  83.     {  //--- name[16],  include,                exclude. (see graphics/displayinfo.h)
  84.        //----------------------------------------------------------------------------
  85.         { "ALL",        DIPF_ALL,               DIPF_NONE },
  86.         { "PAL ONLY",   DIPF_IS_PAL,            DIPF_NONE },
  87.         { "WORKBENCH",  DIPF_IS_WB,             DIPF_NONE },
  88.         { "LACE",       DIPF_IS_LACE,           DIPF_NONE },
  89.         { "HAM/NOLACE", DIPF_IS_HAM,            DIPF_IS_LACE },
  90.         { "NO HAM/EHB", DIPF_ALL,               DIPF_IS_HAM|DIPF_IS_EXTRAHALFBRITE },
  91.         { "ECS/AA",     DIPF_IS_ECS|DIPF_IS_AA, DIPF_NONE },
  92.         { "FOREIGN",    DIPF_IS_FOREIGN,        DIPF_NONE },
  93.     };
  94.  
  95.     PRPT *plist[] =     //---> this list must be passed!
  96.     {
  97.         &proplist[0],
  98.         &proplist[1],
  99.         &proplist[2],
  100.         &proplist[3],
  101.         &proplist[4],
  102.         &proplist[5],
  103.         &proplist[6],
  104.         &proplist[7],
  105.         NULL            //---> end with a NULL pointer!
  106.     };
  107.  
  108.     void main(int argc,char **argv)
  109.     {
  110.     struct Screen *scr;
  111.     SCRMODE scrmode;
  112.     UBYTE name[32];
  113.  
  114.         if (IntuitionBase = OpenLibrary("intuition.library",36))
  115.         {
  116.             if (UserScreenMode(NULL,&scrmode,plist))
  117.             {
  118.                 if (scr = OpenScreenTags (NULL,
  119.                                         SA_Width,       scrmode.Width,
  120.                                         SA_Height,      scrmode.Height,
  121.                                         SA_Depth,       scrmode.Depth,
  122.                                         SA_DisplayID,   scrmode.ModeID,
  123.                                         SA_Overscan,    scrmode.OScan,
  124.                                         SA_FullPalette, TRUE,
  125.                                         SA_SysFont,     1L,
  126.                                         SA_Type,        PUBLICSCREEN,
  127.                                         SA_AutoScroll,  TRUE,
  128.                                         SA_PubName,     "TestScreen",
  129.                                         TAG_END))
  130.                 {
  131.                     Delay(300);
  132.                     CloseScreen(scr);
  133.  
  134.                     if (ModeName(scrmode.ModeID,name))
  135.                     {   printf("You've selected a \"%s\" screen\n",name);
  136.                     }
  137.                 }
  138.             }
  139.             else if (USM_Error) printf("ERROR: %s\n",USM_ERROR);
  140.  
  141.             CloseLibrary(IntuitionBase);
  142.         }
  143.     }
  144.  
  145. -------------------------------------------------------------------------------
  146.  
  147. NAME
  148.     ModeName -- Ask the name of a mode.
  149.  
  150.  
  151. SYNOPSIS
  152.  
  153.     extern int __asm ModeName( register __d0 ULONG ModeID,
  154.                                register __a0 UBYTE *Name );
  155.  
  156.     ok = ModeName( ModeID, Name )
  157.     d0                d0    a0
  158.  
  159. FUNCTION
  160.     This function places the name of the mode in the "Name" buffer.
  161.  
  162. INPUTS
  163.     ModeID
  164.         The ModeID you want to know the name of.
  165.  
  166.     Name
  167.         A pointer to at least 32 bytes of memory. This is where the
  168.         name will be if ModeName() returns TRUE.
  169.  
  170. RESULT
  171.     A TRUE (1) result may be expected if the function found a name for
  172.     this mode. If not, the result will be FALSE (0) and the "Name" buffer
  173.     will not have been changed.
  174.  
  175. NOTE
  176.     This fuction uses its own database for the known modes 'till WB3.0;
  177.     only unknown modes will be looked for in the Graphics-database.
  178.     The reason for this is SPEED; no one likes to wait forever..., besides,
  179.     the graphics-database doesn't know all names; HAM and EHB modes have to
  180.     do without and it takes even more time to create those from names of
  181.     other modes.
  182.     The object uses some memory, though. You will understand.
  183.  
  184. NOTE!
  185.     The fact that this function knows the name of a mode does NOT mean
  186.     that the system supports this mode! Always check the availabillity
  187.     with "if (DisplayInfo.NotAvailable == 0)".
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.